<template>
  <a-table
      :columns="columns"
      :data-source="searchResultData.songs"
      :pagination="false"
  >
    <a slot="name" slot-scope="text">{{ text }}</a>
  </a-table>
</template>

<script>

import {getMusicTime} from "@/utils/util";

export default {
  name: "single",
  data() {
    return {
      searchResultData: {},
      columns: [
        {
          title: '',
          dataIndex: 'sort',
          key: 'sort',
          scopedSlots: {customRender: 'sort'},
          width: 60,
          customRender: function (text, record, index) {
            return index + 1
          }
        },
        {
          title: '',
          dataIndex: 'love',
          key: 'love',
          scopedSlots: {customRender: 'love'},
          width: 30
        },
        // {
        //   title: '2',
        //   dataIndex: 'download',
        //   key: 'download',
        //   scopedSlots: {customRender: 'download'},
        //   width: 30
        // },
        {
          title: '音乐标题',
          dataIndex: 'musicName',
          key: 'musicName',
          scopedSlots: {customRender: 'musicName'},
          customRender: function (text, record) {
            return record.name;
          }
        },
        {
          title: '歌手',
          dataIndex: 'singer',
          key: 'singer',
          customRender: function (text, record) {
            return record.artists[0].name;
          }
        },
        {
          title: '专辑',
          dataIndex: 'album',
          key: 'album',
          ellipsis: true,
          customRender: function (text, record) {
            return record.album.name;
          }
        },
        {
          title: '时长',
          dataIndex: 'duration',
          key: 'duration',
          ellipsis: true,
          width: 100,
          customRender: function (text) {
            return getMusicTime(text / 1000);
          }
        },
        // {
        //   title: '热度',
        //   dataIndex: 'hot',
        //   key: 'hot',
        //   ellipsis: true,
        // },
      ],
    }
  },
  updated() {

  },
  methods: {
    updateSearchResult() {
      this.searchResultData = this.$store.getters.searchResultData;
    },
    getSongs() {
    },
  },
}
</script>

<style scoped>

</style>
